using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CefSharp.Handler;

namespace CefSharp.Wpf.Example.Handlers
{
    public class ResourceRequestHandlerExt : ResourceRequestHandler
    {
        private string userAgent;

        public ResourceRequestHandlerExt(string userAgent)
        {
            this.userAgent = userAgent;
        }
        public ResourceRequestHandlerExt()
        {
            this.userAgent = userAgent;
        }

        protected override CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
        {
            var headers = request.Headers;
            headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36";
            //  headers["referer"] = "http://anya.f3322.net";
            //headers.Add("Referer", "http://www.ericgiguere.com/tools/http-header-viewer.html");
           // request.SetReferrer("http://anya.f3322.net", ReferrerPolicy.Origin);
            request.Headers = headers;
            //return CefReturnValue.Continue;

            return base.OnBeforeResourceLoad(chromiumWebBrowser, browser, frame, request, callback);
        }

    }
}
